package com.oocl.tm.dao.impl;

import java.io.IOException;
import java.io.ObjectOutputStream;
import java.io.OutputStream;

import com.oocl.tm.dao.ClientsDao;
import com.oocl.tm.log4j.Log4j;
import com.oocl.tm.repository.ClientsDBFactory;

public class ClientsDaoImpl implements ClientsDao{

	@Override
	public void delAnOutput(String sender) {
		try {
			ClientsDBFactory.getOutputsList().get(sender).close();
		} catch (IOException e) {
			Log4j.getLogger().error(e, e.fillInStackTrace());
		}
		ClientsDBFactory.getOutputsList().remove(sender);
	}

	@Override
	public void refreshOffline(String sender) {
		ClientsDBFactory.getClientsList().put(sender, false);
	}

	@Override
	public void recordOnline(String sender) {
		ClientsDBFactory.getClientsList().put(sender, true);
	}
	
	@Override
	public void insertAnOutput(String sender, OutputStream oos){
		ClientsDBFactory.getOutputsList().put(sender, oos);
	}

}
